( function(A) {
	A
			.extend(
					A.fn,
					{
						pstrength : function(B) {
							var B = A.extend( {
								verdects : [ "很弱", "弱", "一般", "不错", "非常好" ],
								colors : [ "#cc6", "#c66", "#f60", "#3c0","#3f0" ],
								scores : [ 10, 15, 30, 40 ],
								common : ["123456","liverpool", "letmein",
										"qwerty", "monkey" ],
								minchar :6
							}, B);
							return this
									.each( function() {
										var C = A(this).attr("id");
										
				
										
										A(this).after(
												"<div class=\"pstrength-bar\" id=\""
														+ C
														+ "_minchar\"></div>");
								
								
										A(this).after(
												"<div class=\"pstrength-info\" id=\""
														+ C + "_text\"></div>");
									
										

										A(this).keyup(
												function() {
													A(this).unbind("blur"); 
													
													A.fn.run(A(this)
															.val(), C, B)
												})
						
									})
						},
						run : function(D, F, C) {
							
							function styleCss(o,strColor,strtext,msg){
								
								o.attr("class",msg);
								o.attr("style","line-height:18px;margin-left:12px ;color:" + strColor + ";");
								o.html(strText);
							}
							
							
							nPerc = A.fn.check(D, C);
							var B = "#" + F + "_bar";
							var E = "#" + F + "_text";
							if (nPerc == -200) {
								strColor = "#f00";
								strText = "不安全密码!";
								styleCss(jQuery("#passwordRequried"),strColor,strText,"msg ok");
								A(B).css( {							
									width :"0%"
								})
							} else {
								if (nPerc < 0 && nPerc > -199) {
									strColor = "#cc0000";
									strText = "长度至少6位";
									styleCss(jQuery("#passwordRequried"),strColor,strText,"msg error");
									A(B).css( {
										width :"10%"
									})
								} else {
									if (nPerc <= C.scores[0]) {
										strColor = C.colors[0];
										strText = C.verdects[0];
										styleCss(jQuery("#passwordRequried"),strColor,strText,"msg ok");
										A(B).css( {
											width :"20%"
										})
									} else {
										if (nPerc > C.scores[0]
												&& nPerc <= C.scores[1]) {
											strColor = C.colors[1];
											strText = C.verdects[1];
											styleCss(jQuery("#passwordRequried"),strColor,strText,"msg ok");
											A(B).css( {
												width :"30%"
											})
										} else {
											if (nPerc > C.scores[1]
													&& nPerc <= C.scores[2]) {
												strColor = C.colors[2];
												strText = C.verdects[2];
												styleCss(jQuery("#passwordRequried"),strColor,strText,"msg ok");
												A(B).css( {
													width :"40%"
												})
											} else {
												if (nPerc > C.scores[2]
														&& nPerc <= C.scores[3]) {
													strColor = C.colors[3];
													strText = C.verdects[3];
													styleCss(jQuery("#passwordRequried"),strColor,strText,"msg ok");		
													A(B).css( {
														width :"50%"
													})
												} else {
													strColor = C.colors[4];
													strText = C.verdects[4];
													styleCss(jQuery("#passwordRequried"),strColor,strText,"msg ok");	
													A(B).css( {
														width :"60%"
													})
												}
											}
										}
									}
								}
							}
							A(B).css( {
								backgroundColor :strColor
							});					

							//jQuery("#passwordRequried").html(
							//		"<span style=line-height:18px;padding:8px 10px 2px 23px;margin-left:20px ;color:" + strColor + ";'>"
								//			+ strText + "</span>")
						},				
						
						check : function(C, B) {
							var F = 0;
							var E = B.verdects[0];
							if (C.length < B.minchar) {
								F = (F - 100)
							} else {
								if (C.length >= B.minchar
										&& C.length <= (B.minchar + 2)) {
									F = (F + 6)
								} else {
									if (C.length >= (B.minchar + 3)
											&& C.length <= (B.minchar + 4)) {
										F = (F + 12)
									} else {
										if (C.length >= (B.minchar + 5)) {
											F = (F + 18)
										}
									}
								}
							}
							if (C.match(/[a-z]/)) {
								F = (F + 7)
							}
							if (C.match(/[A-Z]/)) {
								F = (F + 5)
							}
							if (C.match(/\d+/)) {
								F = (F + 5)
							}
							if (C.match(/(.*[0-9].*[0-9].*[0-9])/)) {
								F = (F + 1)
							}
							if (C.match(/.[!,@,#,$,%,^,&,*,?,_,~]/)) {
								F = (F + 5)
							}
							if (C
									.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/)) {
								F = (F + 7)
							}
							if (C.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)) {
								F = (F + 2)
							}
							if (C.match(/([a-zA-Z])/) && C.match(/([0-9])/)) {
								F = (F + 3)
							}
							if (C
									.match(/([a-zA-Z0-9].*[!,@,#,$,%,^,&,*,?,_,~])|([!,@,#,$,%,^,&,*,?,_,~].*[a-zA-Z0-9])/)) {
								F = (F + 3)
							}
							for ( var D = 0; D < B.common.length; D++) {
								if (C.toLowerCase() == B.common[D]) {
									F = -200
								}
							}
							return F
						}
					})
})(jQuery)